//
//  UIView+Extensions.swift
//  扩展文件
//
//  Created by 伏文东 on 2018/2/5.
//  Copyright © 2018年 伏文东. All rights reserved.
//

import UIKit

extension UIView {
    
    /// 返回视图截图
    ///
    /// - Returns: 返回视图截图UIImage
    func snapshotImage() -> UIImage? {
        
        UIGraphicsBeginImageContextWithOptions(self.bounds.size, true, 0)
        
        self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
        
        let result = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return result
    }
}
